﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BySoft.Server.Common.Entity;
using System.Data;
using BySoft.Server.Common.Schema;

namespace BySoft.Web.Site.UserControl
{
    public partial class LeftMenu : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //根据登录的用户获得所有的f级菜单
            if (Session["Login_User"] != null)
            {
                SysUserEntity objUser = ((SysUserEntity)Session["Login_User"]);


                DataTable dtTopModulelist = (DataTable)Session["TopModulelist"];
                DataTable dtMenuList = (DataTable)Session["LeftModulelist"];


                string strHtml = string.Empty;
                DataTable dtnewstype = BySoft.Server.Business.SelectionCatche.GetParametersByType("NewsType");

                for (int i = 0; i < dtTopModulelist.Rows.Count; i++)
                {
                    string display = "style=\"display: none\"";

                    strHtml += "<ul id=\"ul" + dtTopModulelist.Rows[i][SysModuleTable.C_MODULEID].ToString() + "\" " + display + ">";
                    DataRow[] drs = dtMenuList.Select(SysModuleTable.C_PARENTMODULEID + "='" + dtTopModulelist.Rows[i][SysModuleTable.C_MODULEID].ToString() + "'", SysModuleTable.C_ORDERNO);



                    for (int j = 0; j < drs.Length; j++)
                    {
                        if (dtTopModulelist.Rows[i][SysModuleTable.C_MODULENAME].ToString().Equals("内容页管理"))
                        {
                            if (drs[j][SysModuleTable.C_MODULENAME].ToString().Equals("首页"))
                            {
                                continue;
                            }
                        }

                        string sUrl = drs[j][SysModuleTable.C_FUNCTIONURL].ToString();// +sJump;

                        string strmenu = "menu" + sUrl.Replace("/", "").Replace(".aspx", "").Replace("?", "").Replace("=", "");

                        strHtml += "<li ><a style=\"cursor:pointer\" href=\"../" + sUrl + "\"  id=\"" + sUrl.Replace("/", "").Replace(".aspx", "") + "\" target=\"content\" onclick=\"seftleftmenu('" + sUrl + "')\"><span id='" + strmenu + "'>";
                        strHtml += drs[j][SysModuleTable.C_MODULENAME].ToString() + "</span></a></li>";
                    }
                    strHtml += "</ul>";
                }

                divLeftMenu.InnerHtml = strHtml;
            }
        }
    }
}